package com.cims.action.customer;

import java.util.ArrayList;
import java.util.List;

import com.cims.action.BaseAction;
import com.cims.bo.grave.GraveBO;
import com.cims.bo.grave.GraveBOImpl;
import com.cims.bo.land.LandBO;
import com.cims.bo.land.LandBOImpl;
import com.cims.common.vo.Grave;
import com.cims.common.vo.GravePurchased;
import com.cims.common.vo.Land;
import com.cims.common.vo.OrderItem;
import com.cims.common.vo.Staff;

public class ManageOrder extends BaseAction {
	private List<OrderItem> listGraveInOrderItem = new ArrayList<OrderItem>();
	private List<GravePurchased> listGravePurchased = new ArrayList<GravePurchased>();

	private String selectedGrave = "0";
	private int customerId;
	private List<OrderItem> listLand = new ArrayList<OrderItem>();
	private String selectedLand = "0";

	private String GraveLastName = "L";
	private String GraveFirstName = "F";
	private String GraveDOB = "0";
	private String GraveDOD = "0";
	private String GraveHomeTown = "Hanoi";

	// list all order
	public String list() {
		try {
			GraveBO gbo = new GraveBOImpl();
			listGraveInOrderItem = gbo.getListGraveOfCustomer(customerId);

			LandBO lbo = new LandBOImpl();
			listLand = lbo.getListLandOfCustomer(customerId);
			
			listGravePurchased = lbo.getListGravePurchasedOfCustomer(customerId);

		} catch (Exception e) {
			// TODO: handle exception
		}
		return SUCCESS;
	}

	public String createGravePurchased() {
		try {
			LandBO lbo = new LandBOImpl();

			OrderItem graveSelected = new OrderItem();
			graveSelected.setOrderId(Integer.parseInt(selectedGrave));

			Land l = new Land();
			l.setLandId(Integer.parseInt(selectedLand));
			GravePurchased graveP = new GravePurchased();
			graveP.setLand(l);
			graveP.setFirstname(GraveFirstName);
			graveP.setLastname(GraveLastName);
			graveP.setHometown(GraveHomeTown);

			lbo.assignGraveToLand(graveSelected, graveP);
			
			return SUCCESS;
		} catch (Exception ex) {
			return ERROR;
		}
	}

	public int getCustomerId() {
		return customerId;
	}

	public void setCustomerId(int customerId) {
		this.customerId = customerId;
	}

	public List<OrderItem> getListLand() {
		return listLand;
	}

	public void setListLand(List<OrderItem> listLand) {
		this.listLand = listLand;
	}

	public List<OrderItem> getListGraveInOrderItem() {
		return listGraveInOrderItem;
	}

	public void setListGraveInOrderItem(List<OrderItem> listGraveInOrderItem) {
		this.listGraveInOrderItem = listGraveInOrderItem;
	}
	public String getSelectedLand() {
		return selectedLand;
	}

	public void setSelectedLand(String selectedLand) {
		this.selectedLand = selectedLand;
	}

	public String getSelectedGrave() {
		return selectedGrave;
	}

	public void setSelectedGrave(String selectedGrave) {
		this.selectedGrave = selectedGrave;
	}

	public String getGraveLastName() {
		return GraveLastName;
	}

	public void setGraveLastName(String graveLastName) {
		GraveLastName = graveLastName;
	}

	public String getGraveFirstName() {
		return GraveFirstName;
	}

	public void setGraveFirstName(String graveFirstName) {
		GraveFirstName = graveFirstName;
	}

	public String getGraveDOB() {
		return GraveDOB;
	}

	public void setGraveDOB(String graveDOB) {
		GraveDOB = graveDOB;
	}

	public String getGraveDOD() {
		return GraveDOD;
	}

	public void setGraveDOD(String graveDOD) {
		GraveDOD = graveDOD;
	}

	public String getGraveHomeTown() {
		return GraveHomeTown;
	}

	public void setGraveHomeTown(String graveHomeTown) {
		GraveHomeTown = graveHomeTown;
	}
	

	public List<GravePurchased> getListGravePurchased() {
		return listGravePurchased;
	}

	public void setListGravePurchased(List<GravePurchased> listGravePurchased) {
		this.listGravePurchased = listGravePurchased;
	}

}
